class ModalStore {
	store: { open: boolean; title: string; data: any } = { open: false, title: 'modal', data: {} };
	update_store: any = {};

	constructor() {
		this.store.open = false;
	}

	getDetail = () => ({
		store: this.store,
		setModal: this.setModal,
		setUpdateFunc: this.setUpdateFunc
	});

	// 设置更新方法
	setUpdateFunc = (onChange: any) => {
		this.update_store.update = onChange;
	};

	setModal = (open: boolean, title: string, data = {}) => {
		this.store.open = open;
		this.store.title = title;
		this.store.data = data ?? {};
		this.update_store.update?.();
	};
}

export default ModalStore;
